package com.zhentao.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhentao.model.common.business.pojo.BusinessMenu;
import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.service.BusinessMenuService;
import com.zhentao.mapper.BusinessMenuMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author 贾晓婷
* @description 针对表【business_menu】的数据库操作Service实现
* @createDate 2024-09-14 19:03:41
*/
@Service
public class BusinessMenuServiceImpl extends ServiceImpl<BusinessMenuMapper, BusinessMenu>
    implements BusinessMenuService{

    @Resource
    BusinessMenuMapper businessMenuMapper;
    @Override
    public ResponseResult listMenu() {
        List<BusinessMenu> businessMenus = businessMenuMapper.selectList(Wrappers.<BusinessMenu>lambdaQuery().eq(BusinessMenu::getMenuId, 0));
        for (BusinessMenu businessMenu : businessMenus){
            List<BusinessMenu> businessMenus1 = businessMenuMapper.selectList(Wrappers.<BusinessMenu>lambdaQuery().eq(BusinessMenu::getParentId, businessMenu.getMenuId()));
            businessMenu.setBusinessMenuList(businessMenus1);
        }
        return ResponseResult.okResult(businessMenus);
    }
}




